#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
void explode(const char * probe,  char * data ,vector<string> &result);
int main ()
{
    //test svn diff
    cout << "Hello World!"<<endl;
    vector<string> strVector;
    explode("::","test::nihao::3::4::5::6::",strVector);
    for(int i=0; i<strVector.size(); ++i) {
        cout<<strVector[i]<<endl;
    }
    return 0;
}

/*
 *this function is the same as function "explode()" in php
 */

void explode(const char * probe,  char * data ,vector<string> &result)
{
    result.clear();  //initial the vector
    string dataStr(data);
    int pos1 = 0;
    int pos2 = 0;
    int probeLength = strlen(probe);
    while((pos2=dataStr.find(probe,pos1)) != string::npos){
        result.push_back(dataStr.substr(pos1,pos2-pos1));
        pos1=pos2 + probeLength;
    }
    result.push_back(dataStr.substr(pos1));
}    
